#include "balance_account.h"
#include "ui_balance_account.h"
#include"mainwindow.h"
#include<QPainter>
#include<QFont>
#include<QPushButton>
#include"equipmentshop.h"
#include"message.h"
balance_account::balance_account(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::balance_account)
{
//    ui->setupUi(this);
//    this->setGeometry(435,100,700,700);
//    btn3=new QPushButton("返回装备库",this);
//    btn3->move(580,620);
//    btn3->resize(100,50);
//    setFixedSize(700,700);
//    setWindowTitle("结算界面");
//    connect(btn3,&QPushButton::clicked,this,&balance_account::gobackequipmentshop);
}
balance_account::balance_account(int moneynumber,bool isOver,int shengmutakeaway1,int shengmustore1,int numberfinished1): ui(new Ui::balance_account)
{
     ui->setupUi(this);
     this->setGeometry(435,100,700,700);
     btn3=new QPushButton("返回装备库",this);
     btn3->move(580,620);
     btn3->resize(100,50);
     setFixedSize(700,700);
     setWindowTitle("结算界面");
     connect(btn3,&QPushButton::clicked,this,&balance_account::gobackequipmentshop);
     money=moneynumber;
     isgameover=isOver;
     shengmutakeaway=shengmutakeaway1;
     shengmustore=shengmustore1;
     numberfinished=numberfinished1;
}
balance_account::~balance_account()
{
    delete ui;
}
void balance_account::paintEvent(QPaintEvent*event)
{
    //打印游戏结束界面
    QPainter painter(this);
    moneyearned=numberfinished*10;
    if(isgameover==true)
    {
        moneyearned=moneyearned-20;
        shengmustore=shengmustore-shengmutakeaway;
        if(shengmustore<2)
            shengmustore=2;
    }
    QFont font1("Courier",20);
    painter.setFont(font1);
    painter.setPen(Qt::black);
    painter.setBrush(Qt::black);
    painter.drawText(230,260,"本局获得金币");
    painter.drawText(400,260,QString::number(moneyearned));
    money=(moneyearned+money)/10;//将钱给更新
    if(money<10)
        money=10;
}
void balance_account::gobackequipmentshop()
{
    this->close();
    Equipmentshop *equipment1=new Equipmentshop(money,shengmustore);
    equipment1->show();
}
